<?php

namespace App\Http\Resources;

use App\Models\Book;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class BookResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            "id" => $this->id,
            'category_id' => $this->category_id,
            "category" => @Book::$category[$this->category_id],
            "name" => $this->name,
            "full_name" => $this->full_name,
            "introduce" => $this->introduce,
            "word_num" => $this->word_num,
            "publisher" => $this->publisher,
            "cover" => $this->cover,
        ];
    }
}
